#ifndef __TCPSERVER_H__
#define __TCPSERVER_H__

#include <winsock2.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define SOCK_OK 0
//ERROR CODE
#define SOCK_STARTUP_ERR  1
#define SOCK_SOCKET_ERR   2
#define SOCK_BIND_ERR     3
#define SOCK_LISTEN_ERR   4
#define SOCK_ACCEPT_ERR   5
#define SOCK_SEND_ERR     6
#define SOCK_RECV_ERR     7

#include <boost/thread/thread.hpp>

class CTcpServer
{
public:
	CTcpServer();
	~CTcpServer();

	int Start(const char* pcIP,const int iPort);
	int Stop();

	virtual void Handle(const char* pcIP,const int iPort,const char* pcBuf);
	void Send(const char* pcIP,const int iPort,const char* pcBuf); 

	void AcceptThread(int iSocket);

private:

	//local socket
	int _iLocalSocket;
	struct sockaddr_in _addrLocalAddr;

	boost::thread_group _thdsThreads;
	


};

#endif //__TCPSERVER_H__